// Time Tracker by Eric Nadeau (nado18@gmail.com)
// Copyright (C) 2007 by Eric Nadeau
// Distributed under the terms of the GNU General Public License (see GPL.txt)

package tests;

import model.*;
import junit.framework.*;

/**
 * @author Eric Nadeau (nado18@gmail.com), on Apr 21, 2004
 */
public class TimeConverterTest extends TestCase {

	/**
	 * Constructor for TimeConverterTest.
	 * @param arg0
	 */
	public TimeConverterTest(String arg0) {
		super(arg0);
	}

	/*
	 * @see TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
	}

	/*
	 * @see TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testStringToLong() {
		Assert.assertEquals(0, TimeConverter.stringToLong("0"));
		Assert.assertEquals(0, TimeConverter.stringToLong("00"));
		Assert.assertEquals(0, TimeConverter.stringToLong("000"));
		Assert.assertEquals(0, TimeConverter.stringToLong("0:0"));
		Assert.assertEquals(0, TimeConverter.stringToLong("000:000"));
		Assert.assertEquals(0, TimeConverter.stringToLong("0:0:0"));
		Assert.assertEquals(60*60, TimeConverter.stringToLong("1"));
		Assert.assertEquals(60, TimeConverter.stringToLong("0:1"));
		Assert.assertEquals(1, TimeConverter.stringToLong("0:0:1"));
		Assert.assertEquals( ((2*60)+37)*60+29, TimeConverter.stringToLong("2:37:29"));
	}

	public void testLongToString() {
		Assert.assertEquals( "0:00:00", TimeConverter.longToString(0) );
		Assert.assertEquals( "2:37:29", TimeConverter.longToString(((2*60)+37)*60+29) );
		Assert.assertEquals( "100:07:00", TimeConverter.longToString(((100*60)+7)*60) );
	}

}
